package com.wu.ssm.study.threadlocal;

/**
 * Created by wzf on 2018/11/24/024.
 */
public class SequenceC implements Sequence {

    private static MyThreadLocal<Integer> numberc = new MyThreadLocal<Integer>(){
        @Override
        public Integer initialValue() {
            return 0;
        }
    };

    @Override
    public int getNumber() {
        numberc.set(numberc.get() + 1);
        return numberc.get();
    }

    public static void main(String[] args) {
        SequenceC sequencec = new SequenceC();

        ClientThread thread1 = new ClientThread(sequencec);
        ClientThread thread2 = new ClientThread(sequencec);
        ClientThread thread3 = new ClientThread(sequencec);
        thread1.start();
        thread2.start();
        thread3.start();

    }
    
}
